package com.atfzr.interrupt;

import java.util.concurrent.TimeUnit;

/**
 * @author 望夜
 * @date 2023/8/21---9:45
 * @SuppressWarnings({"all"})
 */
public class InterruptDemo2 {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 1; i <= 300; i++) {
                System.out.println("-----:" + i);
            }
            System.out.println("t1线程调用interrupt()后的中断标识2: " + Thread.currentThread().isInterrupted());
        }, "t1");
        t1.start();
        System.out.println("t1线程默认的中断标识：" +    t1.isInterrupted() );

        try {
            TimeUnit.MILLISECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        t1.interrupt();
        System.out.println("t1线程调用interrupt()后的中断标识01：" + t1.isInterrupted());

    }
}
